﻿using TbShop.Business.Components;
using TbShop.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TbShop.Web.Helpers
{
    public static class OperationLogHelper
    {
        public static void SaveOperationLog(string userName, string action, string model, string title, string target = "")
        {
            ServiceComponents<OperationLog> operationLogBC = new ServiceComponents<OperationLog>();
            var log = new OperationLog()
            {
                Action = action,
                Content = action + "了" + model + (string.IsNullOrEmpty(title) ? "" : "的" + title) + (!string.IsNullOrEmpty(target) ? "，编号为【" + target + "】" : "。"),
                OperationTime = DateTime.Now,
                UserId = userName
            };
            log.FillEntity(userName);
            operationLogBC.Save(log);
        }

        public static void SaveOperationLog(string userName, string action, string content)
        {
            ServiceComponents<OperationLog> operationLogBC = new ServiceComponents<OperationLog>();
            var log = new OperationLog()
            {
                Action = action,
                Content = content,
                OperationTime = DateTime.Now,
                UserId = userName
            };
            log.FillEntity(userName);
            operationLogBC.Save(log);
        }
    }
}